package com.jajahome.feature.user.adapter;

import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentStatePagerAdapter;

import com.jajahome.feature.user.fragment.CrowPageFragment;
import com.jajahome.model.CrowModel;

import java.util.List;

/**
 * Created by tuxuesong on 2018/6/5.
 */

public class CrowPagerAdapter extends FragmentStatePagerAdapter {

    private List<CrowModel.DataEntity.CrowdListEntity> mList;//轮播图片信息
    FragmentManager fm;

    public CrowPagerAdapter(FragmentManager fm, List<CrowModel.DataEntity.CrowdListEntity> mList) {
        super(fm);
        this.mList = mList;
        this.fm = fm;
    }

    /**
     * 设置轮播图 数据
     *
     * @param mList 轮播图 数据
     */
    public void setData(List<CrowModel.DataEntity.CrowdListEntity> mList) {
        this.mList = mList;
        notifyDataSetChanged();
    }


    @Override
    public Fragment getItem(int position) {
        return CrowPageFragment.newInstance(mList.get(position));
    }

    @Override
    public int getCount() {
        return mList.size();
    }
}
